<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>保洁时间配置</title>
<link rel="stylesheet" type="text/css"	href="../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/icon.css">
<link href="../static/css/uploadify.css" rel="stylesheet" type="text/css"/>


<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../static/js/index.js"></script>
<script src="../static/js/jquery.uploadify.js" type="text/javascript"></script>

<%
String []nonceObj=ConstantUtils.getNonceObject();
%>

<script type="text/javascript">
var queryParams;
function EasyuiDatagrid() {
	$("#easyui-datagrid").datagrid({
		url: 'content_list.do?f_cc_transcodeStatus=1&f_cc_type=24',//f_cc_type等于24是保洁
		nowrap: true,
		striped: true,
		border: false,
		fit: true,
		rownumbers:true,
		queryParams: getGueryParams(),
		columns: [[
			{field:'id',checkbox:true},
			{field:'f_cc_id',title:'内容ID',align:'center',width:50},
			{field:'f_cc_name',title:'房间号',align:'center',width:150},
			{field:'f_cc_searchname',title:'机顶盒账户',align:'center',width:150},
			{field:'f_cc_interfaceType',title:'第几次清理',align:'center',width:80},
			//{field:'f_cc_companyname',title:'企业名称',align:'center',width:150},
			{field:'f_cc_obligate1',title:'清理日期',align:'center',width:100,
				formatter:function(value,row,index) {
					var str = "";
					if(value!=null)
						str = value.substring(0,10);
					return str;
				}	
			},
			{field:'f_cc_obligate2',title:'清理时间',align:'center',width:80,
				formatter:function(value,row,index) {
					var str = "";
					if(value!=null)
						str = value.substring(0,10);
					return str;
				}	
			},
			{field:'f_cc_transcodeStatus',title:'订单状态',align:'center',width:80,
				formatter:function(value,row,index) {
					var str = "";
					if(value==0){
						str = "没更新过";
						return  str;
					}else if (value==1) {
						str = "更新过";
						return  '<span style="color:red">'+str+'</span>';
					}else if (value==2) {
						str = "已取消";
						return  '<span style="color:red">'+str+'</span>';
					}
					
				}	
			},
			{field:'f_cc_udate',title:'修改时间',align:'center',width:150},
			{field:'_parentId',title:'操作',align:'center',width:150,
				formatter:function(value,row,index){
					str ="";
					str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="onClickBtnDelete(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
					str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="edit(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改</span></span></a>';
		    		if(row.f_cc_type==1)
		    			str+='<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="series(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">剧集管理</span></span></a>';
	    			
	    			<limits:uiAuth url="content_advertisement.jsp">	
	    			if(row.f_cc_type==2 || row.f_cc_type==1)
	    			str+='<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="contentSelectAdvertisement(\''+row.f_cc_id+'\',);" ><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">前插绑定</span></span></a>';
	    			</limits:uiAuth>
	    			<limits:uiAuth url="review_content.do">	
		    		if(row.f_cc_status==2 || row.f_cc_status==4 || row.f_cc_status==7 || row.f_cc_status == 16) {
		    		}
		    		</limits:uiAuth>
			    	return str;
		    	}
			}
		]],
		singleSelect:false,
		pagination:true,
		pageList:[10,20,30,40,50],
		pageSize:10,
		toolbar: '#toolbar',
		
		onExpandRow: function(index,row){
		
		},
		onSelect: function(rowIndex,rowData) {
			
		},
		onUnselect: function(rowIndex,rowData) {
			
		},
		onCheckAll: function(rowIndex,rowData) {
			
		},
		onUncheckAll: function(rowIndex,rowData) {
		
		},
		onLoadSuccess: function(data) {
			if(data.total==-1) {
				$.messager.defaults={ok:"确定",cancel:"取消"};
				$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
				if (r){
				    window.parent.location.href='/login.do';
				    return false;
				}});
			}
		}
	});
}

function getGueryParams(){
	return {
		f_cc_name:$("#f_cc_name").val(),
		f_cc_status:$("#f_cc_status").val(),
		f_cc_type:$("#f_cc_type").val(),
		f_cc_companyid:$("#f_cc_companyid").val()
	};
}

$(function(){
	$.ajax({
		url:"../pms/org_list.do",
		success:function(data) {
			data = JSON.parse(data);
			var str = "";
			for(var i=0;i<data.length;i++) {
				str+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
			}
			$("#f_cc_companyid").append(str);
			
			$("#orgSpan").append($("#f_cc_companyid").clone(true));
		}
	});
	new EasyuiDatagrid();
	gotoSearch = function(){
		$("#easyui-datagrid").datagrid('reload',getGueryParams());
	};
	
	onClickBtnDelete = function(id){
		$.messager.confirm('确定删除内容','确定删除内容么?',function(r){
			if(r){
				app_ajax('delete_content.do?f_cc_id='+id+"&<%=ConstantUtils.getNonce()%>",
				'',
				function(msg){
					if(msg.success) {
						alert("删除成功!");
						if (checkAjaxRequestValidity(msg)) {
							gotoSearch($('#easyui-treegrid'));
							window.location.reload();
						}
					} else {
						alert("删除异常，请联系管理员");
						if($.isFunction(window.showMessager)){
							window.showMessager(msg.resultTitle,msg.result);
						}
					}
				}
				);
			}
		});
	};
	
	$("#chooseOption1").on("change", function(){
		if($(this).val() == 1){
			$("#chooseOption2").show();
		} else {
			$("#chooseOption2").hide();
		}
	});
	
	
});

function SubgridTabOnSelect(title,index){
	setTimeout(function(){
		$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
	},300);
	setTimeout(function(){
		$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
	},3000);
}

function load(){
	$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
}

function _resert(){
	$("#f_cc_name").val("");
	$("#f_cc_status").val("");
}

function onpress(){
	var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
		  	if (event.keyCode == 13){  
  			gotoSearch($('#easyui-treegrid'));
		}
}

function edit(id){
	openDialog($("#dlg"),'content_cleaner_update.jsp?f_cc_id='+id);
}


function add(){
	openDialog($('#dlg'),'content_cleaner_add.jsp');
}

function series(id) {
	openDialog($('#seriesdlg'),'series_list.jsp?f_cc_id='+id);
}




function batchDelete() {
	var rows = $("#easyui-datagrid").datagrid('getSelections');
	var ids = '';
	if(rows.length <= 0) {
		alert("请至少选择一条记录!");
	} else {
		if(confirm("确认是否删除这些记录？")){
			for(var i=0;i<rows.length;i++) {
				ids += rows[i].f_cc_id + ',';
			}
			ids = ids.substring(0, ids.length - 1);
			$.ajax({
				url:"batch_delete_content.do",
				dataType : 'json',
				data : {ids : ids,stime : "<%=nonceObj[0]%>",sign : "<%=nonceObj[1]%>"},
				type : 'get',
				success:function(data) {
					alert(data.result);
					gotoSearch($('#easyui-treegrid'));
					window.location.reload();
				}
			});
		}
	}
}
function contentSelectAdvertisement(id){
	openDialog($('#dlg'),'content_advertisement.jsp?f_cc_id='+id+"&f_ccadver_type=2");
}	
		
	</script>
</head>
<body onload="load();" style="width: 100%;">
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="保洁人员配置"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="48%">
					<tr>
						<td align="left" width="7%">保洁名称：</td>
						<td align="left" width="15%"><input name="f_cc_name" id="f_cc_name" style="width: 150px;" onkeydown="onpress();" /></td>
						
						<td align="left" width="10%">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true" onclick="add()">增加保洁</a>
						</td>
					</tr>
					<tr>
						<td align="left">保洁公司名称:</td>
							<td>
								<select id="f_cc_companyid" name="f_cc_companyid">
									<option value="">--请选择--</option>
								</select>
						</td>
						<td align="left" width="15%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div style="margin-bottom: 5px">
			<!-- <a href="javascript:void(0)" class="easyui-linkbutton" onclick="delete();" iconCls="icon-cut" plain="true">删除</a>  -->
		</div>
	</div>
	<div id="dlg" class="easyui-dialog"
		style="width: 950px; height: 600px; padding-top: 0px;"
		data-options="title:'内容管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
	<div id="seriesdlg" class="easyui-dialog"
		style="width: 1000px; height: 600px; padding-top: 0px;"
		data-options="title:'剧集管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>

</body>
</html>